package cn.fl.system.service;

import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.condition.SysUsrQueryCondition;
import cmm.user.facade.system.dto.SysUsrDTO;
import cn.cmm.base.framework.exception.BaseException;
import cn.fl.login.loginEnum.LoginType;
import cn.fl.system.vo.SysUsrVO;

import java.util.List;

/**
 * @Description: 系统用户表 客户端服务层接口
 * 业务层方法名称前缀：
 * 新增：add*
 * 删除：remove*
 * 修改：modify*
 * 查询对象：select* get*
 * 查询集合：search*
 */
public interface ISysUsrService {
	
	/**
	 * 获取唯一对象
	 * @param id 主键
	 * @return 对象DTO
	 */
	public SysUsrVO selectById(Long id, String sysCd)throws BaseException;
	
	/**
	 * 新增
	 * @param entity
	 * @return
	 */
    public Long add(SysUsrVO entity) throws BaseException;
    
	/**
	 * 新增供应商用户关系,如果用户存在则检查关系,如果有则修改, 没有则新增
	 */
    public Long addForSplUsr(SysUsrVO entity) throws BaseException;

    /**
     * 密码重置
     * @param ids
     * @param pwd
     * @return
     * @throws BaseException
     */
    public boolean modifyPwdSysUsr(List<Long> ids,String pwd)throws BaseException;

    /**
     * 密码重置
     * @param id
     * @param pwd
     * @param sysCd
     * @param mp
     * @return
     * @throws BaseException
     */
    public boolean modifyPwdSysUsr(Long id, String pwd, String sysCd, String mp)throws BaseException;

    /**
     * 修改
     * @param entity
     * @return
     */
    public boolean modify(SysUsrVO entity)throws BaseException;

    /**
     * 分页查询所有
     * @param page
     * @return
     */
    public Pager searchListPage(Pager page)throws BaseException;

    /**
     *人员状态<KEY,VALUE>集合
     * @return <KEY,VALUE>集合
     */
    public List<KeyValueVO> searchIsValidList()throws BaseException;
    /**
     *性别<KEY,VALUE>集合
     * @return <KEY,VALUE>集合
     */
    public List<KeyValueVO> searchGenderCdList()throws BaseException;
    /**
     *类别<KEY,VALUE>集合
     * @return <KEY,VALUE>集合
     */
    public List<KeyValueVO> searchUsrTypCdList()throws BaseException;
    /**
     * 工号唯一验证
     */
    public boolean searchUsrListByUsrNm(SysUsrQueryCondition condition)throws BaseException;
    
    /**
     * 根据系统代码、主键获取用户信息
     * 包括系统用户功能权限数据
     * @param sysCd 系统代码
     * @param usrNm 系统登录名称
     * @return SysUsrDTO
     * @throws BaseException
     */
    public SysUsrDTO selectSysUsrWithAuthBy(String sysCd, String usrNm) throws BaseException;
    
    /**
     * 用户登录
     * @param usrNm 用户名
     * @param pwd 密码
     * @return true false
     * @throws BaseException
     */
    public boolean login(String usrNm, String pwd, LoginType loginType) throws BaseException;

    /**
     * 根据功能权限关联关系分页查询人员列表
     * @param page
     * @return
     * @throws BaseException
     */
    public Pager searchUsrByOrgIdRoleId(Pager page) throws BaseException;
    
    /**
     * 剔除功能权限关联关系分页查询人员列表
     * @param page
     * @return
     * @throws BaseException
     */
    public Pager searchUsrNotInOrgIdRoleId(Pager page) throws BaseException;
    /**
     * 根据数据权限关联关系分页查询人员列表
     * @param page
     * @return
     * @throws BaseException
     */
    public Pager searchUsrByOrgId(Pager page) throws BaseException;
    
    /**
     * 剔除数据权限关联关系分页查询人员列表
     * @param page
     * @return
     * @throws BaseException
     */
    public Pager searchUsrNotInOrgId(Pager page) throws BaseException;
    /**
     * 修改数据权限人员列表
     */
    public Pager searchUsrForUpdate(Pager page) throws BaseException;
    
    /**
     * 切换用户角色和组织
     * @param roleId 指定角色ID
     * @param orgId 指定组织ID
     * @return
     * @throws BaseException
     */
    public boolean modifyCurrentLoginUserInfo(Long roleId, Long orgId) throws BaseException;
    
    /**
     * 根据组织架构ID查询所有属于当前架构角色下所有的人员(属于功能的配置权限)F
     * @param page
     * @return 所有符合条件的人员,如果组织架构ID不存在则查询全部人员
     * @throws BaseException
     */
    public Pager searchFunAuthUsrByOrgId(Pager page) throws BaseException;

    /**
     * 检查用户信息是否存在-修改操作
     * @param usrNm
     * @return
     * @throws BaseException
     */
    public Boolean checkUserInfoForModify(String usrNm, Long id)throws BaseException;
    
    /**
     * 服务端系统代码<KEY,VALUE>集合
     * @return <KEY,VALUE>集合
     */
    public List<KeyValueVO> searchServiceSysCdList()throws BaseException;
    
    /**
     * 不分页查询所有系统用户
     * @author JiLi
     * @param condition
     * @return
     */
    public List<SysUsrDTO> searchSysUsrList(SysUsrQueryCondition condition)throws BaseException;
    
    /**
     * 移除供应商与客户关系信息
     * @param usrId 用户ID
     * @param splId 供应商ID
     * @param usrTypCd 用户类型代码
     * @return 是否成功
     * @throws BaseException
     */
    public boolean removeSplUsrRlInfo(Long usrId, Long splId, String usrTypCd) throws BaseException;

    /**
     * 供应商获取用户
     * @param valueOf
     * @param sysCd
     * @param splId
     * @return
     */
	public SysUsrVO selectByIdAndSplId(Long id, String sysCd, Long splId);

	/**
	 * @MethodName getSysUsrByName
	 * @Description: 通过用户登录名获取用户基本信息
	 * @Author: wangpengtao@lionbridgecapital.cn
	 * @CreateDate: 2019/3/4 13:50
	 * @Version: V1.0.0
	 * @Param usrName
	 * @Return cn.fl.system.vo.SysUsrVO
	 * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
	 */
	public SysUsrDTO getSysUsrByName(String usrName,String sysCd) throws BaseException;

    /**
     * @MethodName getSysUsrByUsrId
     * @Description: 通过用户id获取用户基本信息
     * @Author: wangpengtao@lionbridgecapital.cn
     * @CreateDate: 2019/3/4 13:50
     * @Version: V1.0.0
     * @Param usrName
     * @Return cn.fl.system.vo.SysUsrVO
     * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public SysUsrDTO getSysUsrByUsrId(Long id) throws BaseException;

	/**
	 * @MethodName modifySysUsrMp
	 * @Description: 修改用户手机号码
	 * @Author: wangpengtao@lionbridgecapital.cn
	 * @CreateDate: 2019/3/4 13:51
	 * @Version: V1.0.0
	 * @Param newMp
	 * @Return boolean
	 * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
	 */

	public boolean modifySysUsrMp(String newMp) throws BaseException;

    /**
     * @MethodName getAuthCd
     * @Description: 发送短信验证码信息
     * @Author: wangpengtao@lionbridgecapital.cn
     * @CreateDate: 2019/2/27 16:34
     * @Version: V1.0.0
     * @Param userName
     * @Param code
     * @Return cmm.mid.core.framework.dto.DataResultDTO
     * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public DataResultDTO getAuthCdByUsrNm(String userName,String code) throws BaseException;

    /**
     * @MethodName getAuthCd
     * @Description: 发送短信验证码信息
     * @Author: wangpengtao@lionbridgecapital.cn
     * @CreateDate: 2019/2/27 16:34
     * @Version: V1.0.0
     * @Param userName
     * @Param code
     * @Return cmm.mid.core.framework.dto.DataResultDTO
     * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public DataResultDTO getAuthCdByMp(String mp,String code) throws BaseException;

    /**
     * @MethodName modifySysUsrPwd
     * @Description: 重置密码-校验身份信息
     * @Author: wangpengtao@lionbridgecapital.cn
     * @CreateDate: 2019/2/27 16:34
     * @Version: V1.0.0
     * @Param userName
     * @Param code
     * @Return cmm.mid.core.framework.dto.DataResultDTO
     * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public DataResultDTO verifyIdentity(String usrNm,String msgCode,String verifyCd,String usrMp,String certNo) throws BaseException;

    /**
     * @MethodName checkSysUsrPwd
     * @Description: 验证用户密码是否正确
     * @Author: wangpengtao@lionbridgecapital.cn
     * @CreateDate: 2019/12/23 15:12
     * @Version: V1.0.0
     * @Param usrNm
     * @Param pwd
     * @Return cmm.user.facade.system.dto.SysUsrDTO
     * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public SysUsrDTO checkSysUsrPwd(String usrNm,String pwd) throws BaseException;
    /**
     * @MethodName getResPowerCtrl
     * @Description: 获取菜单权限开关
     * @Author: wangpengtao@lionbridgecapital.cn
     * @CreateDate: 2019/5/7 15:03
     * @Version: V1.0.0
     * @Param
     * @Return java.lang.Boolean
     * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public Boolean getResPowerCtrl() throws BaseException;

    /**
     * 用户系统注销
     * @param usrId
     * @param sysCd
     * @return
     * @throws BaseException
     */
    public boolean usrLogOutInfo(Long usrId,String sysCd) throws BaseException;

    /**
     * @MethodName addSysUsrLoginOutInfo
     * @Description: 用户新增注销记录
     * @Author: wangpengtao@lionbridgecapital.cn
     * @CreateDate: 2020/1/19 15:19
     * @Version: V1.0.0
     * @Param sysUsrCauseCd
     * @Param operDetail
     * @Return java.lang.Long
     * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public Long addSysUsrLoginOutInfo(String sysUsrCauseCd,String operDetail) throws BaseException;
    /**
     * @MethodName usrLogOutInfo
     * @Description: 用户账号锁定
     * @Author: wangpengtao@lionbridgecapital.cn
     * @CreateDate: 2019/12/2 14:59
     * @Version: V1.0.0
     * @Param usrId
     * @Param sysCd
     * @Return boolean
     * @UpdateRemark [序号][YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public boolean usrAccountLock(Long usrId,String sysCd) throws BaseException;

    ListPageVO<SysUsrVO> searchAuthSysUsrList(Pager page, SysUsrQueryCondition qc, String initTime, String orgId, String mgrType, String dataId, String dataTypCd) throws BaseException;

    /**
     * 获取登录是否校验短息登录
     * @return
     */
    public String getCtrlUsrLogin() throws BaseException;

    /**
     * 判断外部用户账号使用期限
     * @param sysUsrDTO
     * @return
     * @throws BaseException
     */
    public boolean checkUsrRegDt(SysUsrDTO sysUsrDTO) throws BaseException;



    /**
     * 分页查询所有金诚用户
     * @param page
     * @return
     */
    public Pager searchJCSplUsrListPage(Pager page)throws BaseException;

    /**
     * 供应商获取金诚用户
     * @param usrId
     * @param splId
     * @return
     */
    public SysUsrVO selectJCSplUsrByIdAndSplId(Long usrId, String splId)throws BaseException;

    /**
     * 新增金诚供应商用户关系,如果用户存在则检查关系,如果有则修改, 没有则新增
     */
    public Long addJCSplUsr(SysUsrVO entity) throws BaseException;

    /**
     * 修改金诚以后
     * @param entity
     * @return
     */
    public boolean modifyJCSplUsr(SysUsrVO entity)throws BaseException;

    /**
     * 移除供应商与客户关系信息
     * @param usrId 用户ID
     * @param splId 供应商ID
     * @return 是否成功
     * @throws BaseException
     */
    public boolean removeJCSplUsrRlInfo(List<Long> usrId, String splId, String employeePosCd) throws BaseException;

    /**
     * 密码重置
     * @param ids
     * @param pwd
     * @return
     * @throws BaseException
     */
    public boolean modifyPwdJCSysUsr(List<Long> ids,String pwd)throws BaseException;

}
